#ifndef _ENCAP_H_
#define _ENCAP_H_

#include <stddef.h>
#include <unistd.h>
#include <termios.h>

#include "ysh.h"

extern void *ec_malloc(size_t size);
extern void ec_free(void *p);

extern int ec_tcsetpgrp(int fildes, pid_t pgid_id);
extern pid_t ec_tcgetpgrp(int fildes);

extern int ec_pipe(int fildes[2]);
//extern int ec_raise(int sig);
extern int ec_kill(pid_t pid, int signo);
extern char *ec_sig2str(int signo);
extern pid_t ec_wait(int *stat_loc);
// TRUE: FOREGROUND
// FALSE: BACKGROUND
#define WAITPID_FG ((int)0)
#define WAITPID_BG ((int)1)
extern int ec_waitpid(pid_t pid, int *stat_loc, int options, int fg_or_bg);

extern int ec_tcsetattr(int fildes, int opt, const struct termios *termptr, tcflag_t flag);
extern int ec_tcgetattr(int fildes, struct termios *termptr);

// Modify the return value to indicate length of hostname.
extern int ec_gethostname(char *name, int namelen);
extern char *ec_getcwd(char *buf, size_t size);

#endif

